<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>login</title>
</head>
<body>
<table id="loginTable">
    <tr>
        <td>
            账号
        </td>
        <td>
            <input name="account" id="account"/>
        </td>
    </tr>
    <tr>
        <td>
            密码
        </td>
        <td>
            <input name="password" id="password" type="password"/>
        </td>
    </tr>
    <tr>
        <td>
            <button id="login">登录</button>
        </td>
        <td>
            <button id="register">注册</button>
        </td>
    </tr>
</table>
<div id="index">
    <p id="uid"></p>
    <p id="allNumber"></p>
    <div id="contentBox">

    </div>
</div>
</body>
<script src="js/jQuery.js"></script>
<script src="js/var.js"></script>
<script>
    let sys = {
        login: false,
    }

    let user = {
        account: undefined,
        password: undefined,
        uid: undefined,
    }
    let dom = {
        loginTable: document.getElementById("loginTable"),
        index: document.getElementById("index"),
        account: document.getElementById("account"),
        password: document.getElementById("password"),
        login: document.getElementById("login"),
        register: document.getElementById("register"),
        uid: document.getElementById("uid"),
        allNumber: document.getElementById("allNumber"),
    }

    function login_() {
        user.account = dom.account.value;
        user.password = dom.password.value;
        let back = ajax("/user/login", user);
        if (backError(back)) {
            dom.loginTable.style.display = "none";
            dom.index.style.display = "block";
            user.uid = back.uid;
            dom.uid.innerText = "my uid:" + user.uid;
            sys.login = true;
            whenLogin();
        }
    }

    function whenLogin() {
        if (sys.login) {

        }
    }

    dom.login.addEventListener("click", login_);
    window.onload = function () {
        dom.index.style.display = "none"
    }
</script>
</html>